/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-05-11 18:11:41
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-03-07 15:35:55
 * @FilePath: /hr_new_vue3/src/apis/management/human/humanChange/leave/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/* 人事-基础设置-入职管理列表api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_API_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
const baseURL2 = env.VITE_APP_BASE_URL;

// 创建入职手续
export function PostEntryProcedure(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce',
    method: 'post',
    baseURL: baseURL,
    data
  });
}

// 获取入职手续详情
export function GetEntryProcedureDetail(params: { id: number; type: 2 }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 编辑入职手续
export function PutEntryProcedure(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 修改入职状态（同步到人员详情的接口）
export function PutEntryProcedureStatus2Human(data: {
  id: number;
  status: 0 | 1 | 2; //0初始状态 1保存状态 2发起状态
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce/ep',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 修改入职手续状态
export function ChangeEntryProcedureStatus(data: {
  id: number;
  status: 0 | 1 | 2; //0待办理 1办理中 2已办理
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce/status',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 修改入职方案审批状态
export function ChangeEntryApprovalStatus(data: {
  id: number;
  status: number; // '1未发起 2等待审核 3审核中 4通过 5拒绝'
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/onboarding/status',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 新增入职申请方案
export function PostEntryApplicationSetting(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/application',
      method: 'post',
      baseURL,
      data
    },
    {
      mode: 'success',
      message: '新增成功'
    }
  );
}

// 修改入职申请方案
export function PutEntryApplicationSetting(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/application',
      method: 'put',
      baseURL,
      data
    },
    {
      mode: 'success',
      message: '修改成功'
    }
  );
}

// 获取入职申请方案列表
export function GetEntryApplicationSetting(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/application',
    method: 'get',
    baseURL,
    params
  });
}

// 获取入职申请方案详情
export function GetEntryApplicationSettingDetail(params: {
  id: number;
  cId?: number;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/application/detail',
    method: 'get',
    baseURL,
    noToken: true,
    params
  });
}

// 获取入职申请方案详情
export function DelEntryApplicationSetting(data: { ids: number[] }) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/application',
      method: 'delete',
      baseURL,
      data
    },
    {
      mode: 'success',
      message: '删除成功'
    }
  );
}
